package cn.com.gzheroli.bfw.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import cn.com.gzheroli.bfw.mapper.system.AppVersionMapper;
import cn.com.gzheroli.bfw.pojo.base.AppVersionEntity;
import cn.com.gzheroli.service.bfw.appVersionService;


@Service("appVersionService")
public class appVersionServiceImpl 
  implements appVersionService
{
  private static Logger logger = LoggerFactory.getLogger(appVersionServiceImpl.class);
  
  
  @Resource
	private AppVersionMapper appVersionMapper;

  
  public Long selectAppVersionAcount(HttpServletRequest request)
  {
    Long size = Long.valueOf(0L);
    StringBuilder roleIds = new StringBuilder();

    Map parameter=new HashMap();
    String version=request.getParameter("version");
    String platform=request.getParameter("platform");
    parameter.put("version", version);
    parameter.put("platform", platform);
	size=appVersionMapper.getAppVersionCount(parameter);

    return size;
  }

  //获取列表
  public List getAppVersionList(HttpServletRequest request)
  {
    Integer page = Integer.valueOf(Integer.parseInt(request.getParameter("page")));
    Integer rows = Integer.valueOf(Integer.parseInt(request.getParameter("rows")));
    Integer start = Integer.valueOf((page.intValue() - 1) * rows.intValue())+1;
    Integer end = Integer.valueOf(page.intValue() * rows.intValue() );
    List results=new ArrayList();
    Map parameter=new HashMap();
    List tempList=new ArrayList();
    String version=request.getParameter("version");
    String platform=request.getParameter("platform");
    parameter.put("version", version);
    parameter.put("platform", platform);
    parameter.put("maxResults", end.intValue());
	parameter.put("firstResult", start.intValue());
	parameter.put("pageSize", end.intValue()-start.intValue()+1);
    List list=appVersionMapper.getAppVersionList(parameter);
    return list;
  }
  
  public AppVersionEntity getAppVersion(String id) {
		// TODO Auto-generated method stub
		return appVersionMapper.getAppVersion(id);
	}
  
  public String getVersion(String a)
  {
	  Map parameter=new HashMap();
	  parameter.put("platform", a);
	  String b=appVersionMapper.getVersion(parameter);
	  return b;
  }
  
  public AppVersionEntity getCodeAddress(HttpServletRequest request){
	  Map parameter=new HashMap();
	  String platform=request.getParameter("platform");
	  parameter.put("platform", platform);
	  AppVersionEntity app=appVersionMapper.getCodeAddress(parameter);
	  return app;
	  
  }
  
  public AppVersionEntity getWgt(HttpServletRequest request){
	  Map parameter=new HashMap();
	  String platform=request.getParameter("platform");
	  parameter.put("platform", platform);
	  AppVersionEntity app=appVersionMapper.getWgt(parameter);
	  return app;
  }
  
  public AppVersionEntity getMaxVersion(HttpServletRequest request){
	  Map parameter=new HashMap();
	  String platform=request.getParameter("platform");
	  parameter.put("platform", platform);
	  AppVersionEntity app=appVersionMapper.getMaxVersion(parameter);
	  return app;
  }
}